<?php
class RM_User_SipsController extends RM_Controller
{
    /**
     * Presnets the CC form
     */
    public function formAction()
    {

        $bookingref = RM_Reservation_Manager::getInstance()->getReservationID();
        $userdetails = RM_Reservation_Manager::getInstance()->getUser()->toArray();

        $plugin = new RM_Plugin_PayPal();
        $reservationsModel = new RM_Reservations();
        $chargetotal = $plugin->getTotalPrice($reservationsModel->find($bookingref)->current());
        RM_Reservation_Manager::getInstance()->setPaymentTotal($chargetotal);

        $model = new RM_Sips_Service();
        $model->checkoutCCForm($chargetotal, $bookingref, $userdetails);
    }

    /**
     * The ajax controller for processing the form 
     */
    public function processAction(){

        $model = new RM_Sips_Service();
        $model->processResponse();
              
    }

    public function ccFormAction(){

    }
    
    public function cancelAction(){
        //We need to reset user object accorting to ticket #59 in Trac
        RM_Reservation_Manager::getInstance()->resetUser();

        // return a cancelled message
        return array(
            'data' => array('success' => true)
        );
    }

    public function successAction(){

        RM_Reservation_Manager::getInstance()->setPaymentStatus(RM_Payments_Status::TRANSACTION_END_SUCCESSFULLY);
        $this->_forward('success', 'payments');
    }
}